<script setup>
// 导入必要的组件和样式
import { ref } from 'vue'

// 轮播图数据 - 国内新闻
const carouselItems = [
  {
    id: 1,
    title: "内地老头头月饼横江汇 被湖南前高管私吞1.3亿买楼车",
    image: "https://images.unsplash.com/photo-1604014052607-e05296b13c30?q=80&w=1000&auto=format&fit=crop",
    link: "#"
  },
  {
    id: 2,
    title: "7岁女童被泳池排水口吸入死亡 挖掘机挖到半夜才挖出女",
    image: "https://images.unsplash.com/photo-1516683639004-5a0d4e6c39c3?q=80&w=1000&auto=format&fit=crop",
    link: "#"
  },
  {
    id: 3,
    title: "上海夫妻为宝宝取名闹到离婚 孩子1岁多还上不了户口",
    image: "https://images.unsplash.com/photo-1535382303607-2022f319d164?q=80&w=1000&auto=format&fit=crop",
    link: "#"
  }
]

// 当前轮播图索引
const currentSlide = ref(0)

// 切换轮播图
function nextSlide() {
  currentSlide.value = (currentSlide.value + 1) % carouselItems.length
}

// 自动轮播
setInterval(nextSlide, 5000)
</script>

<template>
  <div class="news-container">
    <!-- 轮播图区域 -->
    <div class="carousel-container">
      <div class="carousel" :style="{ backgroundImage: `url(${carouselItems[currentSlide].image})` }">
        <a :href="carouselItems[currentSlide].link" class="carousel-link">
          <div class="carousel-overlay">
            <h2 class="carousel-title">{{ carouselItems[currentSlide].title }}</h2>
          </div>
        </a>
        <div class="carousel-indicators">
          <div 
            v-for="(item, index) in carouselItems" 
            :key="item.id"
            class="indicator"
            :class="{ active: index === currentSlide }"
            @click="currentSlide = index"
          ></div>
        </div>
      </div>
    </div>
    
    <!-- 内容区 -->
    <div class="content-wrapper">
      <!-- 主要新闻区（左侧） -->
      <div class="main-content">
        <!-- 要闻区域 -->
        <section class="headlines">
          <h3 class="section-title">国内要闻</h3>
          <div class="news-list">
            <div class="news-item highlight">
              <a href="#" class="news-link">
                <h3 class="news-title">内地老头头月饼横江汇 被湖南前高管私吞1.3亿买楼车</h3>
                <p class="news-summary">湖南省纪委监委通报一起典型违纪违法案件</p>
                <span class="news-source">网易新闻</span>
              </a>
            </div>
            
            <div class="news-item">
              <a href="#" class="news-link">
                <h3 class="news-title">7岁女童被泳池排水口吸入死亡 挖掘机挖到半夜才挖出女</h3>
                <span class="news-source">新京报</span>
              </a>
            </div>
            
            <div class="news-item">
              <a href="#" class="news-link">
                <h3 class="news-title">上海夫妻为宝宝取名闹到离婚 孩子1岁多还上不了户口</h3>
                <span class="news-source">澎湃新闻</span>
              </a>
            </div>
            
            <div class="news-item">
              <a href="#" class="news-link">
                <h3 class="news-title">中国激光防空系统横空出世 "世界最强"或能击落敌方战斗机</h3>
                <span class="news-source">科技日报</span>
              </a>
            </div>
            
            <div class="news-item">
              <a href="#" class="news-link">
                <h3 class="news-title">"张亮麻辣烫没有张亮了"登上热搜 实控人退出直接股东</h3>
                <span class="news-source">财经网</span>
              </a>
            </div>
          </div>
        </section>
        
        <!-- 视频新闻区 -->
        <section class="video-news">
          <h3 class="section-title">国内视频</h3>
          <div class="video-list">
            <div class="video-item">
              <a href="#" class="video-link">
                <div class="video-thumbnail">
                  <img src="https://images.unsplash.com/photo-1569269117004-ea2070903a86?q=80&w=300&auto=format&fit=crop" alt="视频缩略图">
                  <span class="video-duration">04:12</span>
                </div>
                <p class="video-title">月饼横江汇事件深度调查：资金流向追踪</p>
              </a>
            </div>
            
            <div class="video-item">
              <a href="#" class="video-link">
                <div class="video-thumbnail">
                  <img src="https://images.unsplash.com/photo-1571008615382-42660da7d401?q=80&w=300&auto=format&fit=crop" alt="视频缩略图">
                  <span class="video-duration">06:35</span>
                </div>
                <p class="video-title">泳池安全隐患调查：排水口吸力有多大？</p>
              </a>
            </div>
            
            <div class="video-item">
              <a href="#" class="video-link">
                <div class="video-thumbnail">
                  <img src="https://images.unsplash.com/photo-1622547902823-7c41830706a2?q=80&w=300&auto=format&fit=crop" alt="视频缩略图">
                  <span class="video-duration">03:28</span>
                </div>
                <p class="video-title">中国激光武器技术突破：从实验室到战场</p>
              </a>
            </div>
          </div>
        </section>
      </div>
      
      <!-- 侧边栏（右侧） -->
      <aside class="sidebar">
        <!-- 热门排行 -->
        <div class="hot-news">
          <h3 class="sidebar-title">国内热门排行</h3>
          <ul class="hot-list">
            <li class="hot-item">
              <span class="rank-number top">1</span>
              <a href="#" class="hot-link">内地老头头月饼横江汇 被湖南前高管私吞1.3亿买楼车</a>
            </li>
            <li class="hot-item">
              <span class="rank-number top">2</span>
              <a href="#" class="hot-link">7岁女童被泳池排水口吸入死亡 挖掘机挖到半夜才挖出女</a>
            </li>
            <li class="hot-item">
              <span class="rank-number top">3</span>
              <a href="#" class="hot-link">上海夫妻为宝宝取名闹到离婚 孩子1岁多还上不了户口</a>
            </li>
            <li class="hot-item">
              <span class="rank-number">4</span>
              <a href="#" class="hot-link">中国激光防空系统横空出世 "世界最强"或能击落敌方战斗机</a>
            </li>
            <li class="hot-item">
              <span class="rank-number">5</span>
              <a href="#" class="hot-link">"张亮麻辣烫没有张亮了"登上热搜 实控人退出直接股东</a>
            </li>
            <li class="hot-item">
              <span class="rank-number">6</span>
              <a href="#" class="hot-link">"张京巅峰谈判没有说完了"登上热搜 实控人退出直接股东</a>
            </li>
            <li class="hot-item">
              <span class="rank-number">7</span>
              <a href="#" class="hot-link">新三届生回望高考：这份九旬院士的高考作文</a>
            </li>
          </ul>
        </div>
        
        <!-- 广告区域 -->
        <div class="ad-container">
          <a href="#" class="ad-link">
            <img src="https://images.unsplash.com/photo-1574571718236-89611004e1e9?q=80&w=300&auto=format&fit=crop" alt="广告图片" class="ad-image">
          </a>
        </div>
        
        <!-- 推荐阅读 -->
        <div class="recommended">
          <h3 class="sidebar-title">国内推荐</h3>
          <div class="recommended-list">
            <div class="recommended-item">
              <a href="#" class="recommended-link">
                <div class="recommended-image">
                  <img src="https://images.unsplash.com/photo-1593784991055-47a6d006f095?q=80&w=100&auto=format&fit=crop" alt="推荐阅读图片">
                </div>
                <p class="recommended-title">月饼行业潜规则调查：成本几何？利润多少？</p>
              </a>
            </div>
            
            <div class="recommended-item">
              <a href="#" class="recommended-link">
                <div class="recommended-image">
                  <img src="https://images.unsplash.com/photo-1488751172020-3e193fed48a7?q=80&w=100&auto=format&fit=crop" alt="推荐阅读图片">
                </div>
                <p class="recommended-title">儿童泳池安全指南：家长必知的防护措施</p>
              </a>
            </div>
          </div>
        </div>
      </aside>
    </div>
  </div>
</template>

<style scoped>
/* 轮播图样式 */
.carousel-container {
  width: 100%;
  height: 400px;
  margin-bottom: 30px;
  overflow: hidden;
  border-radius: 5px;
}

.carousel {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  position: relative;
  transition: background-image 0.5s ease;
}

.carousel-link {
  display: block;
  width: 100%;
  height: 100%;
}

.carousel-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.8), rgba(0,0,0,0));
}

.carousel-title {
  color: #fff;
  font-size: 24px;
  font-weight: bold;
  margin: 0;
}

.carousel-indicators {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

.indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: rgba(255,255,255,0.5);
  cursor: pointer;
}

.indicator.active {
  background-color: #fff;
}

/* 内容区布局 */
.content-wrapper {
  display: flex;
  gap: 30px;
}

.main-content {
  flex: 3;
}

.sidebar {
  flex: 1;
}

/* 主要新闻样式 */
.headlines {
  margin-bottom: 40px;
}

.section-title {
  font-size: 20px;
  font-weight: bold;
  color: #c80000;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #c80000;
}

.news-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.news-item {
  padding: 10px 0;
  border-bottom: 1px solid #eee;
}

.news-item.highlight {
  padding-bottom: 20px;
}

.news-link {
  text-decoration: none;
  color: #333;
  display: block;
}

.news-link:hover .news-title {
  color: #c80000;
}

.news-title {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 8px;
  line-height: 1.4;
  transition: color 0.3s;
}

.news-summary {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
  line-height: 1.5;
}

.news-source {
  font-size: 12px;
  color: #999;
}

/* 视频新闻样式 */
.video-news {
  margin-bottom: 40px;
}

.video-list {
  display: flex;
  gap: 20px;
}

.video-item {
  flex: 1;
}

.video-link {
  text-decoration: none;
  color: #333;
  display: block;
}

.video-thumbnail {
  position: relative;
  margin-bottom: 10px;
}

.video-thumbnail img {
  width: 100%;
  height: auto;
  border-radius: 5px;
}

.video-duration {
  position: absolute;
  bottom: 5px;
  right: 5px;
  background-color: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 12px;
  padding: 2px 5px;
  border-radius: 3px;
}

.video-title {
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
}

.video-title:hover {
  color: #c80000;
}

/* 侧边栏样式 */
.sidebar-title {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #eee;
}

/* 热门排行样式 */
.hot-news {
  margin-bottom: 30px;
}

.hot-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.hot-item {
  margin-bottom: 15px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.rank-number {
  width: 24px;
  height: 24px;
  background-color: #eee;
  color: #666;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  flex-shrink: 0;
}

.rank-number.top {
  background-color: #c80000;
  color: #fff;
}

.hot-link {
  text-decoration: none;
  color: #333;
  font-size: 14px;
  line-height: 1.4;
  flex: 1;
}

.hot-link:hover {
  color: #c80000;
}

/* 广告样式 */
.ad-container {
  margin-bottom: 30px;
}

.ad-link {
  display: block;
}

.ad-image {
  width: 100%;
  height: auto;
  border-radius: 5px;
}

/* 推荐阅读样式 */
.recommended {
  margin-bottom: 30px;
}

.recommended-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.recommended-item {
  display: flex;
  gap: 10px;
}

.recommended-link {
  display: flex;
  text-decoration: none;
  color: #333;
}

.recommended-image {
  flex-shrink: 0;
  width: 100px;
  height: 70px;
  overflow: hidden;
  border-radius: 3px;
}

.recommended-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recommended-title {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.recommended-title:hover {
  color: #c80000;
}

/* 响应式设计 */
@media (max-width: 1024px) {
  .content-wrapper {
    flex-direction: column;
  }
  
  .video-list {
    flex-direction: column;
  }
  
  .carousel-container {
    height: 300px;
  }
}

@media (max-width: 768px) {
  .carousel-container {
    height: 200px;
  }
  
  .carousel-title {
    font-size: 18px;
  }
  
  .main-title h1 {
    font-size: 32px;
  }
  
  .news-title {
    font-size: 16px;
  }
}
</style>